Explorar o código

Filter out missing CGM readings from TIR (> 30 minutes)

(cherry picked from commit fada6927121c1b07eb07572858f2e1046e3069ad)
Jon Mårtensson %!s(int64=3) %!d(string=hai) anos
pai
achega
ab7eddae85
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      FreeAPS/Sources/APS/APSManager.swift

+ 3 - 2
FreeAPS/Sources/APS/APSManager.swift

@@ -1258,9 +1258,10 @@ final class BaseAPSManager: APSManager, Injectable {
                     lastIndex = true
                 }
                 if array[i].bg_ < Double(hypoLimit), !lastIndex {
-                    timeInHypo += (currentTime - previousTime).timeInterval
+                    // Exclude duration between CGM readings which are more than 30 minutes
+                    timeInHypo += min((currentTime - previousTime).timeInterval, 30.minutes.timeInterval)
                 } else if array[i].bg_ >= Double(hyperLimit), !lastIndex {
-                    timeInHyper += (currentTime - previousTime).timeInterval
+                    timeInHyper += min((currentTime - previousTime).timeInterval, 30.minutes.timeInterval)
                 }
             }
             if timeInHypo == 0.0 {